﻿{include file='pub/header'/}
<title>订单列表</title>
</head>
<body class="pos-r">
<div>
    <nav class="breadcrumb">{$breadNav} <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                           href="javascript:location.replace(location.href);" title="刷新"><i
            class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="page-container">
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover table-sort">
                <thead>
                <tr class="text-c">
                    <th width="50">订单编号</th>
                    <th width="60">下单时间</th>
                    <th width="60">下单会员</th>
                    <th width="30">订单状态</th>
                    <th width="30">支付方式</th>
                    <th width="30">订单总金额</th>
                    <th width="60">支付总金额</th>
                    <th width="60">申请退款时间</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                {foreach $list as $item}
                <tr class="text-c va-m">
                    <td>{$item.order_no}</td>
                    <td>{$item.create_time}</td>
                    <td>{$item.username}</td>
                    <td>{:config('order_status')[$item.order_status]}</td>
                    <td>{:config('pay_type')[$item.pay_type]}</td>
                    <td>{$item.shop_cost}</td>
                    <td>{$item.real_cost}</td>
                    <td>{:date('Y-m-d',$item.refund_time)}</td>
                    <td class="td-manage">
                        <a style="text-decoration:none" class="ml-5" onClick="order_detail('{$item.id}')"
                           href="javascript:;" title="订单详情">
                            <i class="Hui-iconfont">&#xe623;</i>订单详情
                        </a>
                        <a style="text-decoration:none" class="ml-5" onClick="order_refund('{$item.order_no}', '{$item.refund_money}')"
                           href="javascript:;" title="确认退款">
                            <i class="Hui-iconfont">&#xe623;</i>确认退款
                        </a>
                        <a style="text-decoration:none" class="ml-5" onClick="order_refuse('{$item.order_no}', '{$item.refund_money}')"
                           href="javascript:;" title="拒绝退款">
                            <i class="Hui-iconfont">&#xe623;</i>拒绝退款
                        </a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
    </div>
</div>

{include file='pub/footer'/}
<script type="text/javascript">
    $('.table-sort').dataTable({
        "aaSorting": [[1, "desc"]],//默认第几个排序
        "bStateSave": false,//状态保存
    });

    //订单详情
    function order_detail(order_id) {
        layer_show('订单详情', "{:url('Order/order_detail')}?order_id=" + order_id);
    }

    //确认退款
    function order_refund(order_no, default_money) {
        layer.prompt({
            formType: 3,
            value: default_money,
            title: '请输入退款金额'
        }, function (val) {
            $.post("{:url('order_refund')}", {'order_no': order_no, 'status':1, 'money':val}, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        location.reload();
                    }, 888);
                } else {
                    layer.msg(res.msg);
                }
            });
        });
    }

    //拒绝退款
    function order_refuse(order_no) {
        layer.prompt({
            formType: 2,
            value: "",
            title: '请输入拒绝原因'
        }, function (val) {
            $.post("{:url('order_refund')}", {'order_no': order_no, 'status':0, 'reason':val}, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        location.reload();
                    }, 888);
                } else {
                    layer.msg(res.msg);
                }
            });
        });
    }

</script>
</body>
</html>